<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入1-100之间的整数" v-model="number">
  <hr>
  <button @click="guess()">猜一猜</button>
  <h1>{{result}}</h1>
</template>

<script setup>
import {ref} from "vue";

const number = ref(0);
const result = ref();

const random = parseInt(Math.random() * 100 ) + 1;

const guess = () => {
  console.log(random)
  if (number.value > random){
    result.value = "猜大了";
  }else if (number.value < random){
    result.value = "猜小了";
  }else if (number.value == random){
    result.value = "猜对了";
  }
}

</script>

<style scoped>

</style>